@using Microsoft.AspNetCore.Identity
@using OrchardCore.Entities
@using OrchardCore.Settings
@using OrchardCore.Users
@using OrchardCore.Users.Models
@using OrchardCore.DisplayManagement.Razor
@model OrchardCore.Users.ViewModels.LoginViewModel
@inject SignInManager<IUser> SignInManager
@inject ISiteService SiteService
@inject UserManager<IUser> UserManager;
@{
    ViewLayout = "Layout__Login";

    var userCanRegister = (await SiteService.GetSiteSettingsAsync()).As<RegistrationSettings>().UsersCanRegister == UserRegistrationType.AllowRegistration;
    var allowResetPassword = (await SiteService.GetSiteSettingsAsync()).As<ResetPasswordSettings>().AllowResetPassword;
    var loginProviders = (await SignInManager.GetExternalAuthenticationSchemesAsync()).ToList();
    var disableLocalLogin = (await SiteService.GetSiteSettingsAsync()).As<LoginSettings>().DisableLocalLogin;
}
    <h1 class="login">@T["Log in"]</h1>
    <p class="login h4"><a href="@Url.Content("~/")"><i class="icon fas fa-cubes mr-2"></i>@(Site.SiteName)</a></p>
    <div class="login row">
        @if (loginProviders.Count > 0 || userCanRegister)    
        {
        <div class="flex-fill col-lg-4 col-md-6 col-12">
            @if (loginProviders.Count > 0) {     
            <section class="section-panel mb-4">
                <h2 class="text-center mb-3">@T["Log in with"]</h2>
                <form asp-controller="Account" asp-action="ExternalLogin" asp-route-returnurl="@ViewData["ReturnUrl"]" method="post" class="d-flex justify-content-center">
                    <div class="d-flex flex-column justify-content-center">
                        @foreach (var provider in loginProviders)
                        {
                            <button type="submit" class="btn btn-lg btn-primary m-2 nav-link is-rounded" name="provider" value="@provider.Name" title="@provider.DisplayName">
                                @if (provider.DisplayName == "GitHub") { <i class="fab fa-github mr-2"></i> } 
                                @if (provider.DisplayName == "Azure") { 
                                    <i class="mr-2" aria-hidden="true">
                                        <svg width="24px" height="24px" viewBox="0 0 48 48" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;">
                                            <path d="M26.23,4.85L12.07,17.12L0,38.79L10.89,38.79L26.23,4.85ZM28.11,7.72L22.07,24.74L33.65,39.29L11.19,43.15L48,43.15L28.11,7.72Z" style="fill:white;fill-rule:nonzero;"/>
                                        </svg>
                                    </i>
                                } @provider.DisplayName
                            </button>
                            @if (disableLocalLogin)
                            {   
                                <br />
                            }
                        }
                    </div>
                </form>
            </section>
            }
        </div>
        }
        @if (!disableLocalLogin)
        {
        <div class="flex-fill col-lg-4 col-md-6 col-12">
            <section>
                <h2 class="text-center">@T["Digital account"]</h2>
                <form asp-controller="Account" asp-action="Login" asp-route-returnurl="@ViewData["ReturnUrl"]" method="post" class="auth-form">
                    <div asp-validation-summary="ModelOnly" class="text-danger"></div>
                    <div class="form-group d-flex flex-column align-items-center justify-content-center py-2">
                        <label class="asterix" asp-for="UserName">@T["Username"]</label>
                        <input asp-for="UserName" class="form-control" aria-describedby="UserName-described-by" autocomplete="username" />
                        <span id="UserName-described-by" asp-validation-for="UserName" class="text-danger"></span>
                    </div>
                    <div class="form-group d-flex flex-column align-items-center justify-content-center py-2">
                        <label class="asterix" asp-for="Password">@T["Password"]</label>
                        <input asp-for="Password" class="form-control" aria-describedby="Password-described-by" autocomplete="current-password"  />
                        <span id="Password-described-by" asp-validation-for="Password" class="text-danger"></span>
                    </div>
                    <div class="form-group custom-control custom-checkbox d-flex justify-content-center mt-4 mb-1">
                        <input asp-for="RememberMe" class="custom-control-input" />
                        <label asp-for="RememberMe" class="custom-control-label">@T["Remember me"]</label>
                    </div>
                    @await RenderSectionAsync("AfterLogin", required: false)
                    <div class="d-flex justify-content-center py-2">
                        <button type="submit" class="btn btn-lg btn-primary is-rounded"><span>@T["Log in"]</span></button>
                    </div>
                    @if (allowResetPassword)
                    {
                    <div class="d-flex justify-content-center mt-4">
                        <a class="h4" asp-controller="ResetPassword" asp-action="ForgotPassword" class="label-link">@T["Forgot your password?"]</a>
                    </div>
                    }
                </form>
            </section>
        </div>
        }
    </div>
    <div class="login row mt-4">
        @if (userCanRegister)
        {
        <div class="flex-fill col-lg-8 col-md-12 col-12">
            <section class="section-panel d-flex justify-content-center py-4">
                <a class="btn btn-lg btn-outline-primary is-rounded" asp-controller="Registration" asp-action="Register" asp-route-returnurl="@ViewData["ReturnUrl"]">@T["Create an account"]</a>
            </section>
        </div>
        }
    </div>